#include<bits/stdc++.h>
using namespace std;
set<pair<int, int> > res;
double p[100010], d[100010], v[100010], a[100010];
inline double  sq(double& x) {
    return x * x;
}
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    cin >> T;
    while (T--) {
        res.clear();
        int n, m;
        double L, V;
        cin >> n >> m >> L >> V;
        for (int i = 0; i < n; ++i) {
            scanf("%lf%lf%lf", d + i, v + i, a + i);
        }
        for (int i = 0; i < m; ++i) {
            scanf("%lf", p + i);
        }
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            int pi = lower_bound(p, p + m, d[i]) - p;
            if (pi >= m)continue;
            if (a[i] == 0.0) {
                if (v[i] > V) {
                    ++cnt;
                    res.insert(make_pair(pi, m - 1));
                }
            } else if (a[i] < 0.0) {
                if (v[i] > V) {
                    double fp = d[i] + (sq(V) - sq(v[i])) / (a[i] * 2);
                    int fpi = lower_bound(p, p + m, fp) - p - 1;
                    if (fpi >= pi) {
                        ++cnt;
                        res.insert(make_pair(pi, fpi));
                    }
                }
            } else if (a[i] > 0.0) {
                if (v[i] > V) {
                    ++cnt;
                    res.insert(make_pair(pi, m - 1));
                } else {
                    double sp = d[i] + (sq(V) - sq(v[i])) / (a[i] * 2);
                    int spi = upper_bound(p, p + m, sp) - p;
                    if (spi < m) {
                        ++cnt;
                        res.insert(make_pair(spi, m - 1));
                    }
                }
            }
        }
        printf("%d ", cnt);
        cnt = 0;
        int pe = L;
        res.insert(make_pair(m, m));
        for (auto i = res.begin(); i != res.end(); ++i) {
            if (i->first > pe) {
                ++cnt;
                pe = i->second;
            }
            pe = min(pe, i->second);
        }
        cout << m - cnt << endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}